import React, { useState } from "react";
import my from './my.scss';
import { Link, useNavigate } from "react-router-dom";
import Footer from 'components/Footer'
// import { useLocation } from 'react-router';


function My() {
    const navigate = useNavigate()
    console.log(1111, localStorage.UserStore.phone);
    console.log(22, JSON.parse(localStorage.UserStore).phone);
    // const location = useLocation();
    // console.log(123, location);
    // let [login, setlogin] = useState
    const isLogin = () => {

        if (JSON.parse(localStorage.UserStore).phone) {
            localStorage.setItem('token', '')
            localStorage.setItem('localStorage.UserStore.phone', '')
            navigate("/login")
        }
    }
    return (
        <div className="my-my">
            <div className="app">
                {/* // <!-- 头部图片 --> */}
                <div className="header flex aic ">
                    <img src={require('./avatar.png')} className="my-img" alt="" />
                    {!!location ? <div><p className=" f16 fff ml-10">{JSON.parse(localStorage.UserStore).phone}</p></div> : <Link to={"/login"}><p className=" f16 fff ml-10" >立即登录</p></Link>}
                    {/* {!!location.state?<div><p className=" f16 fff ml-10">{location.state.phone}</p></div>: <Link to={"/login"}><p className=" f16 fff ml-10" >立即登录</p></Link>} */}


                </div>
                {/* //  个人中心列表数据  */}

                <div className="bg-fff mt-10 pl-20 pr-10">
                    <Link to={"/order"} className=" flex list f18 jc-sb aic">
                        <p className="f14">我的订单</p>
                        <span className="f888 icon iconfont f18 icon-yuanquanyoujiantou am-icon-md"></span>
                    </Link>

                    <div className=" flex list f18 jc-sb aic">
                        <p className="flex f14">我的共享卡</p>
                        <span className="f888 icon iconfont f18 icon-yuanquanyoujiantou am-icon-md"></span>
                    </div>
                    <div className=" flex list f18 jc-sb aic">
                        <p className="flex f14">我的优惠卷</p>
                        <span className="f888 icon iconfont f18 icon-yuanquanyoujiantou am-icon-md"></span>
                    </div>
                    <Link to={"/my/collection"} className=" flex list f18 jc-sb aic">
                        <p className="flex f14">我想去</p>
                        <span className="f888 icon iconfont f18 icon-yuanquanyoujiantou am-icon-md"></span>
                    </Link>
                    <Link to={"/my/track"} className=" flex list f18 jc-sb aic">
                        <p className="flex f14">我的足迹</p>
                        <span className="f888 icon iconfont f18 icon-yuanquanyoujiantou am-icon-md"></span>
                    </Link>
                    <div onClick={isLogin} className=" flex list f18 jc-sb aic">
                        <p className="flex f14">退出登录</p>
                        <span className="f888 icon iconfont f18 icon-yuanquanyoujiantou am-icon-md"></span>
                    </div>

                </div>

                <Footer active="04" />
            </div>
        </div>
    )
}

export default My